package com.snopy.designPattern.structure.bridge.impl;

import com.snopy.designPattern.structure.bridge.inter.Device;

/**
 * @author snopy
 * @version 1.0.0
 * @classname Tv
 * @description
 * @email 77912204@qq.com
 * @date 2022/11/26 21:40
 */
public class Tv implements Device {

    private boolean on = false;
    private int volume = 30;
    private int channel = 1;
    @Override
    public boolean isEnabled() {
        return on;
    }

    @Override
    public void enabled() {
        this.on = true;
    }

    @Override
    public void disabled() {
        this.on = false;
    }

    @Override
    public int getVolume() {

        return volume;
    }

    @Override
    public void setVolume(int percent) {
        if (volume > 100) {
            this.volume = 100;
        } else if (volume < 0) {
            this.volume = 0;
        } else {
            this.volume = volume;
        }
    }

    @Override
    public int getChannel() {
        return channel;
    }

    @Override
    public void setChannel(int channel) {
        this.channel = channel;
    }

    @Override
    public void printStatus() {
        System.out.println("------------------------------------");
        System.out.println("| I'm TV set.");
        System.out.println("| I'm " + (on ? "enabled" : "disabled"));
        System.out.println("| Current volume is " + volume + "%");
        System.out.println("| Current channel is " + channel);
        System.out.println("------------------------------------\n");
    }
}
